<template>
  <f7-page>
    <f7-navbar title="查询结果" back-link="Back"></f7-navbar>
    <f7-list media-list v-for="(room, index) in object" :key="index">
      <f7-list-item
        link="#"
        @click="Type(room.Type,room.Price,room.status)"
        :title="room.Name"
        :after="room.status"
        :subtitle="room.Type"
        :text="room.Price"
      >
        <img slot="media" :src="`data:image/jpeg;base64,${room.Photo}`" width="60">
      </f7-list-item>
      <!-- <a href="#" class="item-link item-content">
        <div class="item-inner item-cell">
          <div class="item-col">
        <img
          slot="media"
          src="@/assets/reservation/hotel.jpg"
          width="80"
        >
          </div>
        </div>
      </a>-->
    </f7-list>
  </f7-page>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      object: []
    };
  },
  mounted() {
    this.selectBookingRoom();
    console.log(this.$store.state.apiData.day);
  },
  methods: {
    selectBookingRoom() {
      const self = this;
      const app = self.$f7;
      self.$f7.dialog.preloader("加载中");
      URL = "/caofuying/Booking/selectBookingRoom";
      axios
        .get(URL, {
          params: {
            startdate: this.$store.state.apiData.startdate,
            enddate: this.$store.state.apiData.enddate
          }
        })
        .then(r => {
          const { data } = r;
          if (data !== null) {
            this.object = data;
            self.$f7.dialog.close();
          } else {
            app.dialog.alert("服务器错误");
          }
        });
    },
    Type(Typepay, Price,status) {
      if(status==="可定"){
        this.$f7router.navigate("/createorder/");
      }
      let apiPrice = {
        Typepay,
        Price
      };
      this.$store.commit("setapiPrice", apiPrice);
    }
  }
};
</script>